<?php
/**
 * Punny - The most easy-to-use PHP MVC framework
 * 
 * Copyright (c) 2010  
 *
 * @author email :lx.xin@qq.com
 */
 require('BaseController.php');
 class Admin_TagController extends Admin_BaseController{
	var $tag;
	function init(){
		parent::init();
		$this->tag=new Tag();
	}
	/*
	 *tag列表
	 */
	function indexAction(){
		$numPerPage = 10;
		$getPage = $this->_request->getParam('page');
		$page = empty($getPage)?'1':$getPage;
		//抓回所有要显示的记录
		$array=$this->tag->getTag();
		//Zend_debug::dump($array);
		//factory出一个分页并且设置当前页码与每页显数
		$paginator = Zend_Paginator::factory($array);
		$paginator->setCurrentPageNumber($page)
				  ->setItemCountPerPage($numPerPage);
         //把分页显示到view
		$this->view->paginator = $paginator;		
		echo $this->view->render('tag.html');
	}
	/*
	 *删除tag
	 */
	function delAction(){
		$id=$this->_request->get('id');
		if($id>0){
			$this->tag->delTag($id);
			$this->view->url=$this->_request->getBaseUrl()."/admin/tag/";
			$this->view->msg="删除成功";
			echo  $this->view->render('success.html');
		}
		else{
			$this->view->url=$this->_request->getBaseUrl()."/admin/tag/";
			$this->view->msg="要删除的数据不存在";
			echo $this->view->render('error.html');
		}
	}
	 
 }
 ?>